This repository was archived by the owner on Feb 22, 2023. It is now read-only.
[webview_flutter] Filter onChanged events for invalid displays#1964
Merged
amirh merged 3 commits intoflutter:masterfrom Aug 9, 2019
Merged
[webview_flutter] Filter onChanged events for invalid displays#1964amirh merged 3 commits intoflutter:masterfrom
amirh merged 3 commits intoflutter:masterfrom
Conversation
93fed39 to
63b421d
Compare
mklim
approved these changes
Aug 9, 2019
|
|
||
| /** Should be called prior to the webview's initialization. */ | ||
| void onPreWebViewInitialization(DisplayManager displayManager) { | ||
| listenersBeforeWebView = yoinkDisplayListeners(displayManager); |
Contributor
Author
There was a problem hiding this comment.
Learned from the best 😄
| /** Should be called after the webview's initialization. */ | ||
| void onPostWebViewInitialization(final DisplayManager displayManager) { | ||
| final ArrayList<DisplayListener> listeners = yoinkDisplayListeners(displayManager); | ||
| // We recorded |
Contributor
There was a problem hiding this comment.
nit: Is this comment incomplete?
| @@ -38,6 +38,7 @@ | |||
| /* End PBXCopyFilesBuildPhase section */ | |||
Contributor
There was a problem hiding this comment.
nit: The changes in this file look like they could be reverted.
.../webview_flutter/android/src/main/java/io/flutter/plugins/webviewflutter/FlutterWebView.java
Show resolved
Hide resolved
sungmin-park
pushed a commit
to sungmin-park/flutter-plugins
that referenced
this pull request
Dec 17, 2019
…er#1964) Works around an Android WebView bug that was causing a crash by filtering some DisplayListener invocations. Older Android WebView versions had assumed that when DisplayListener#onDisplayChanged is invoked, the display ID it is provided is of a valid display. However it turns out that when a display is removed Android may call onDisplayChanged with the ID of the removed display, in this case the Android WebView code tries to fetch and use the display with this ID and crashes with an NPE. The issue was fixed in the Android WebView code in https://chromium-review.googlesource.com/517913 which is available starting WebView version 58.0.3029.125 however older webviews in the wild still have this issue. Since Flutter removes virtual displays whenever a platform view is resized the webview crash is more likely to happen than other apps. And users were reporting this issue see: flutter/flutter#30420 This change works around the webview bug by unregistering the WebView's DisplayListener, and instead registering our own DisplayListener which delegates the callbacks to the WebView's listener unless it's a onDisplayChanged for an invalid display.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Works around an Android WebView bug that was causing a crash by filtering some DisplayListener invocations.
Older Android WebView versions had assumed that when
DisplayListener#onDisplayChangedis invoked, the display ID it is provided is of a valid display. However it turns out that when a display is removed Android may call onDisplayChanged with the ID of the removed display, in this case the Android WebView code tries to fetch and use the display with this ID and crashes with an NPE.The issue was fixed in the Android WebView code in https://chromium-review.googlesource.com/517913 which is available starting WebView version 58.0.3029.125 however older webviews in the wild still have this issue.
Since Flutter removes virtual displays whenever a platform view is resized the webview crash is more likely to happen than other apps. And users were reporting this issue see: flutter/flutter#30420
This change works around the webview bug by unregistering the WebView's DisplayListener, and instead registering our own DisplayListener which delegates the callbacks to the WebView's listener unless it's a onDisplayChanged for an invalid display.
Related Issues
Fixes flutter/flutter#30420
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]). This will ensure a smooth and quick review process.///).flutter analyze) does not report any problems on my PR.Breaking Change
Does your PR require plugin users to manually update their apps to accommodate your change?